﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace BanXeTang
{
    public abstract class Character : VisibleGameEntity
    {
        public int nDelay;
        protected int iDelay;
        public int huong;//huong len 0, huong sang phai 1, huong xuong 2, huong sang trai 3

        public override bool Init(ContentManager Content, int n, string strResource)
        {
            _nsprite = 4;
            _sprite = new MySprite[_nsprite];

            Texture2D[] texture2dUp = new Texture2D[n];
            Texture2D[] texture2dRight = new Texture2D[n];
            Texture2D[] texture2dDown = new Texture2D[n];
            Texture2D[] texture2dLeft = new Texture2D[n];
            for (int i = 0; i < n; i++)
                texture2dUp[i] = Content.Load<Texture2D>(@"Pictures/" + strResource + "_Up" + i.ToString("00"));
            _sprite[0] = new MySprite(texture2dUp, X, Y);

            for (int i = 0; i < n; i++)
                texture2dRight[i] = Content.Load<Texture2D>(@"Pictures/" + strResource + "_Right" + i.ToString("00"));
            _sprite[1] = new MySprite(texture2dRight, X, Y);

            for (int i = 0; i < n; i++)
                texture2dDown[i] = Content.Load<Texture2D>(@"Pictures/" + strResource + "_Down" + i.ToString("00"));
            _sprite[2] = new MySprite(texture2dDown, X, Y);

            for (int i = 0; i < n; i++)
                texture2dLeft[i] = Content.Load<Texture2D>(@"Pictures/" + strResource + "_Left" + i.ToString("00"));
            _sprite[3] = new MySprite(texture2dLeft, X, Y);

            return true;
        }

        public override void UnDo()
        {
            if (huong == 0)
            {
                //len
                Y = Y + 2;
            }
            else if (huong == 1)
            {
                //phai
                X = X - 2;
            }
            else if (huong == 2)
            {
                //xuong
                Y = Y - 2;
            }
            else if (huong == 3)
            {
                //trai
                X = X + 2;
            }

        }
       
    }
}
